#pragma once

class rational {
friend bool operator<(const rational &, const rational &);
friend bool operator==(const rational &, const rational &);
public:
    rational(int i); 
    rational(int n, int d); 
    rational(const rational& r);
    rational& operator=     (const rational& r); 

    rational& operator+=    (const rational& r); 
    rational& operator-=    (const rational& r); 
    rational& operator*=    (const rational& r); 
    rational& operator/=    (const rational& r); 
    rational& operator++    ();
    rational  operator++    (int);
    rational& operator--    ();
    rational  operator--    (int);

    operator double () const;

    void swap (rational& r);
    rational& neg ();
    rational& rev ();

    void print () const;
private:
    void normalize ();

    int n_, d_;
};


rational operator+ (const rational& a, const rational& b);
rational operator- (const rational& a, const rational& b);
rational operator* (const rational& a, const rational& b);
rational operator/ (const rational& a, const rational& b);


bool operator== (const rational& a, const rational& b);
bool operator!= (const rational& a, const rational& b);
bool operator<= (const rational& a, const rational& b);
bool operator>= (const rational& a, const rational& b);
bool operator<  (const rational& a, const rational& b);
bool operator>  (const rational& a, const rational& b);

